package com.haibei.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

public class PercentView extends View {

	private float percent;
	private Paint paint;
	private int color=0xffbbffaa;

	public PercentView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	void init() {
		paint = new Paint();
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		int w = getWidth();
		int h = getHeight();
		int rx = 10;
		int ry = 10;
		RectF rect = new RectF();
		rect.left = 0;
		rect.top = 0;
		rect.bottom = h;
		rect.right = w;
		paint.setColor(color);
		canvas.drawRoundRect(rect, rx, ry, paint);
	}

	public float getPercent() {
		return percent;
	}

	public void setPercent(float percent) {
		this.percent = percent;
		invalidate();
	}

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;
		invalidate();
	}

}
